package cn.springcloud.fix.gateway.controller;

import cn.springcloud.fix.common.core.base.R;
import cn.springcloud.fix.gateway.service.VersionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/version")
public class GatewayVersionController {

    @Autowired
    private VersionService versionService;

    @RequestMapping(value = "/add", method = RequestMethod.GET)
    public String add(Model model) {
        int result = versionService.addVersion();
        model.addAttribute("result", result);
        return "addVersion";
    }

    /**
     * 获取最后一次发布的版本号
     */
    @RequestMapping(value = "/lastVersion", method = RequestMethod.GET)
    public R<Long> getLastVersion() {
        return versionService.getLastVersion();
    }
}
